package ifreecomm.nettyserver.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * Created by wang on 2018/12/29.
 */

public class AutoBrainEncoder extends MessageToByteEncoder <AutoBrainProtocol>{
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, AutoBrainProtocol autoBrainProtocol, ByteBuf byteBuf) throws Exception {
        byteBuf.writeInt(autoBrainProtocol.getHead_data());
        //byteBuf.writeByte(0x23);
        //byteBuf.writeShort(BytesConvertUtils.bytesToShort(startSymbol));
       // byteBuf.writeInt(autoBrainProtocol.getContentLength());
        byteBuf.writeBytes(autoBrainProtocol.getContent());
        byteBuf.writeByte(0x24);
        byteBuf.writeByte(0x24);
    }
}
